﻿@using System.Web.Http
@using System.Web.Http.Controllers
@using System.Web.Http.Description
@using epalpay.api.help
@using epalpay.api.help.Models
@model IGrouping<HttpControllerDescriptor, ApiDescription>

@{
    var controllerDocumentation = ViewBag.DocumentationProvider != null ?
        ViewBag.DocumentationProvider.GetDocumentation(Model.Key) :
        null;
}

<h2 id="@Model.Key.ControllerName">@Model.Key.ControllerName</h2>
@if (!String.IsNullOrEmpty(controllerDocumentation)) {
    <p>@controllerDocumentation</p>
}
<table class="help-page-table">
    <thead>
        <tr><th>API</th><th>Description</th><th>Authorize</th></tr>
    </thead>
    <tbody>
        @foreach (var api in Model) {
        	if(api.ActionDescriptor.GetCustomAttributes<System.ObsoleteAttribute>().Count()==0){
            int index = api.RelativePath.IndexOf('?');
            <tr>
                <td class="api-name"><a href="@Url.Action("Api", "Help", new { apiId = api.GetFriendlyId() })">@api.HttpMethod.Method @(index != -1 ? api.RelativePath.Substring(0, index) : api.RelativePath)</a></td>
                <td class="api-documentation">
                    @if (api.Documentation != null) {
                        <p>@api.Documentation</p>
                    } else {
                        <p>No documentation available.</p>
                    }
                </td>
				<td>@(api.ActionDescriptor.GetCustomAttributes<System.Web.Http.AllowAnonymousAttribute>().Count()>0?"不需要":"授权访问")</td>
            </tr>
            }
        }
    </tbody>
</table>